<template>
  <div>
    <el-form label-width="100px" size="small" :label-position="left" v-if="form">
      <el-row :gutter="80" style="display: flex;flex-wrap: wrap">

        <el-col :span="8">
          <el-form-item label="检验单号：">
            <span>{{form.inspection_no}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="请验类型：">
            <span>{{form.inspection_type_name}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="检验目的：">
            <span>{{form.inspection_goal || '常规检验'}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="项目名称：">
            <span>{{form.project_name}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="项目编号：">
            <span>{{form.project_no}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="检品名称：">
            <span>{{form.sample_info.name}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="检验项目：">
            <span>{{form.inspection_project	 || '无'}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="样品类型：">
            <span v-if="form.sample_info.sample_type_info">{{form.sample_info.sample_type_info.same_type_name	}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="CAS：">
            <span>{{form.sample_info.cas}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="生产日期：">
              <span
                v-if="form.sample_info.production_date">{{dateFormat1('yyyy-mm-dd',form.sample_info.production_date)}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="有效期：">
              <span
                v-if="form.sample_info.validity_date">{{dateFormat1('yyyy-mm-dd ',form.sample_info.validity_date)}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="送检量：">
            <span>{{form.sample_num}}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="送检量单位：">
            <span>{{form.sample_info.unit}}</span>
          </el-form-item>
        </el-col>

        <template v-for="(item,index) in    form.sample_info.batch_info">
          <el-col :span="8">
            <el-form-item label="批号：">
              <span>{{item.sample_batch	}}</span>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="booleBoole">
            <el-form-item label="批量：">
              <span>{{item.batch_num}}</span>
            </el-form-item>
          </el-col>
        </template>

        <template v-if="booleBoole">
          <el-col :span="8">
            <el-form-item label="批量单位：">
              <span>{{form.batch_unit}}</span>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="是否留样：">
              <span v-if="form.if_reserve_sample === 1">是</span>
              <span v-else>否</span>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="form.if_reserve_sample === 1 && form.inspection_type !=='inspection_type_wd'">
            <el-form-item label="贮存条件：">
              <span>{{form.storage_conditions}}</span>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="form.inspection_type ==='inspection_type_wd'">
            <el-form-item label="贮存条件：">
              <span>{{form.storage_conditions}}</span>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="form.inspection_header">
            <el-form-item label="检验负责人：">
              {{form.inspection_header.name}}
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="form.inspection_joiner">
            <el-form-item label="检验人：">
              {{calculate(form.inspection_joiner)}}

            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="经销商：">
              <span>{{form.sample_info.supplier}}</span>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="生产商：">
              <span>{{form.sample_info.producer}}</span>
            </el-form-item>
          </el-col>

<!--          <el-col :span="8">-->
<!--            <el-form-item label="来源：">-->
<!--              {{form.source}}-->
<!--            </el-form-item>-->
<!--          </el-col>-->

<!--          <el-col :span="8">-->
<!--            <el-form-item label="实验目的：">-->
<!--              {{form.experiment_goal}}-->
<!--            </el-form-item>-->
<!--          </el-col>-->

          <el-col :span="8" v-if="form.inspection_date">
            <el-form-item label="检验期限：">
              <span
                v-if="form.inspection_date">{{dateFormat1('yyyy-mm-dd ',form.inspection_date)}}</span>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="请验人：">
              <span>{{form.creator_name}}</span>
            </el-form-item>
          </el-col>
        </template>

        <el-col :span="8">
          <el-form-item label="是否返样：">
            <span v-if="form.if_return_sample === 0">否</span>
            <span v-if="form.if_return_sample === 1">是</span>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="check_num > 0">
          <el-form-item label="返样量：">
            {{check_num}}
          </el-form-item>
        </el-col>


        <el-col :span="24">
          <el-form-item label="备注：">
            <span>{{form.remark}}</span>
          </el-form-item>
        </el-col>

        <template v-if="booleBoole">
          <el-col :span="12" v-if="form.quality_standard_file.length > 0">
            <el-form-item label="检验依据：">
              <file-preview :file-list="form.quality_standard_file" :fileBtnOption="['preview']"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="厂检报告：">
              <file-preview :file-list="form.factory_inspection_report" :fileBtnOption="['preview']"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="合成路线：">
              <file-preview :file-list="form.synthetic_route" :fileBtnOption="['preview']"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="附件：">
              <file-preview :file-list="form.enclosure" :fileBtnOption="['preview']"/>
            </el-form-item>
          </el-col>
        </template>


      </el-row>
    </el-form>
  </div>
</template>

<script>
  export default {
    name: 'taskForm',
    props: {
      form: {
        type: Object,
        default: function() {
          return {}
        }
      },
      check_num: {
        type: Number,
        default() {
          return 0
        }
      },
      booleBoole: {
        type: Boolean,
        default() {
          return false
        }
      }
    },
    data() {
      return {
        left: 'left'
      }
    },
    //是计算属性，也可以理解为一个方法。
    computed: {
      calculate() {
        return function(val) {
          let str = ''
          for (let i = 0; i < val.length; i++) {
            str += val[i].name
            if (i !== val.length - 1) {
              str = str + '、'
            }
          }
          return str
        }
      }
    },

    //属性是手动定义的所需监听的值
    watch: {},

    //生命周期 - 创建完成（访问当前this实例）
    created() {
    },

    //生命周期 - 挂载完成（访问DOM元素）
    mounted() {
    },

    //是Vue实例对象上绑定的方法，供当前Vue组件作用域内使用，
    methods: {}

  }

</script>

<style scoped>
  /* @import url(); 引入css类 */
</style>
